package com.ecarx.vhaltests.hy11.testcases.brightness;

import android.util.Log;

import com.ecarx.vhaltests.IpcpClient;
import com.ecarx.vhaltests.VhalUnitTestBase;

import org.junit.Assert;

public class BrightnessTestBase extends VhalUnitTestBase {

    private static final String TAG = "BrightnessTestBase";

    private static final int SERVICE_ID_CEM = 37;
    private static final int OP_ID_CEM = 999;

    public void mockAmbIllmnFwdStsAmblillmn1And2(int amb1, int amb2) {
        IpcpClient ipcpClient = new IpcpClient();
        int cemSvcId = SERVICE_ID_CEM;
        int cemOperId = OP_ID_CEM;
        int[] cemOperIds = {OP_ID_CEM};
        ipcpClient.setConfig(cemSvcId, cemOperIds);
        String[] cems = {"ambIllmnFwdStsAmblillmn1", "ambIllmnFwdStsAmblillmn2"};
        int[] cemValues = {amb1, amb2};
        boolean dd = ipcpClient.setCEMSignal(cemSvcId, cemOperId, cems, cemValues);
        Log.d(TAG, "mockDayNightTwliBriSts setCEMSignal:" + dd);
        delay();
    }

    public void mockDayNightTwliBriSts(boolean isday) {
        IpcpClient ipcpClient = new IpcpClient();
        int cemSvcId = SERVICE_ID_CEM;
        int cemOperId = OP_ID_CEM;
        int[] cemOperIds = {OP_ID_CEM};
        ipcpClient.setConfig(cemSvcId, cemOperIds);
        String[] cems = {"twliBriSts"};
        int[] cemValues = {isday ? 1 : 0};
        boolean dd = ipcpClient.setCEMSignal(cemSvcId, cemOperId, cems, cemValues);
        Log.d(TAG, "mockDayNightTwliBriSts setCEMSignal:" + dd + ",isday:" + isday);
        delay();
    }

    public void setCarConfig(int config, int value) {
        IpcpClient ipcpClient = new IpcpClient();
        int ccSvcId = 135;
        int ccOperId = 200;
        int[] configs = {config};
        int[] values = {value};
        ipcpClient.setConfig(ccSvcId, new int[]{ccOperId});
        boolean ccResult = ipcpClient.setCarconfigSignal(ccSvcId, ccOperId, configs, values);
        Assert.assertTrue(ccResult);
        delay();
    }

    public void setIsLowEndModel(boolean isLowEndModel) {
        setCarConfig(352, isLowEndModel ? 0x03 : 0x80);
//        setCarConfig(401, isLowEndModel ? 0x02 : 0x01);
    }

}
